import java.io.DataOutputStream;
import java.io.OutputStream;
import java.net.Socket;

class ClientRunnable implements Runnable {

    @Override
    public void run() {

        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            OutputStream os = socket.getOutputStream();
            DataOutputStream dos = new DataOutputStream(os);
            for (int i = 1; i <= 5; i++) {
                Thread.sleep(200);
                if (i == 5) {
                    dos.writeUTF("exit");
                } else {
                    dos.writeUTF(Thread.currentThread().getName() + "的第" + i + "次：Hello");
                }
            }
            dos.close();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}